package com.zhuqi.proxy.service.handle;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author : ZhuQi
 * @version : 时间:2021/12/13 14:08 版本:
 * @description : 代理类
 */
public class RentHandel implements InvocationHandler {

    private Object targetObject;

    public RentHandel(Object targetObject) {
        this.targetObject = targetObject;
    }

    @Override
    public Object invoke(Object o, Method method, Object[] objects) throws Throwable {

        System.out.println("代理前");
        // 执行代理方法
        for (Object object : objects) {
            System.out.println(object);
        }
        Object invoke = method.invoke(targetObject, objects);
        System.out.println("代理后");
        return invoke;
    }
}
